<script>
	$(document).ready(function() {	
		//add dialog
		$("#add")
			.button()
			.click(function(){
				$("#dialog-add").dialog("open");
			});
		$("#dialog-add").dialog({
			autoOpen: false,
			height:300,
			width:350,
			modal:true,
			buttons:{
				"add": function(){
					if ( $("#formadd").validationEngine('validate') ) {
						$.ajax({
							url: "<?php echo base_url();?>index.php/admin/user_add",
							type: "POST",
							data: $("#formadd").serialize(),
							timeout: 10000,
							dataType: "json"
						}).done(function(data){
								if(data.status===true){
									field1.val("");
									$( "#dialog-add" ).dialog( "close" );
									$("#tbl").dataTable().fnAddData([
										"a","b","c","d","e"
									]);
								}else{
									alert (data.pesan);
								}
							}).fail(function(jqXHR, textStatus){
								alert ('Terjadi kesalahan koneksi' + textStatus);
								$( "#dialog-add" ).dialog( "close" );
						});
					}
				},
				Cancel: function() {
					$( this ).dialog( "close" );
					$('#formadd').validationEngine('hideAll');
				}
			},
			close: function() {
				$('#formadd').validationEngine('hideAll');
			}
		});		
	});
</script>

<div id="dialog-add" title="Form Pemesanan">
  <form>
  <fieldset>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
    <label for="email">Email</label>
    <input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
  </fieldset>
  </form>
</div>